<template>
  <t-dialog
    header="验收编号列表"
    :visible.sync="visible"
    :onClose="closeDialog"
    :closeOnOverlayClick="false"
    :confirm-btn="null"
    width="80%"
    top="5%"
  >
  <div style="height: 65vh">
    <t-form  ref="form" :data="queryParams" label-width="80" @submit="()=>{this.getList()}" @reset="()=>{this.getList()}">
      <t-row style="border-bottom: 1px solid #E5E6EB;margin-bottom: 10px">
        <t-col :span="11" class="query-form-inline">
          <t-form-item label="年份" name="year">
            <t-date-picker mode="year" style="width: 240px" clearable v-model="queryParams.year">

            </t-date-picker>
          </t-form-item>
        </t-col>
        <t-col :span="1" class="operation-container">
          <t-button theme="primary" type="submit"> 查询</t-button>
          <t-button theme="default" variant="outline" type="reset">重置</t-button>
        </t-col>
      </t-row>
    </t-form>
    <t-table
      rowKey="id"
      :data="data"
      :columns="columns"
      hover
      :loading="dataLoading"
    >
    </t-table>
  </div>
  </t-dialog>
</template>

<script>
export default {
  name: "acceptance-num-list",
  props:{
    year: {
      type: String,
      default: ''
    }
  },
  data(){
    return {
      visible: true,
      dataLoading: false,
      data: [],
      columns: [
        {
          colKey: "name",
          title: "验收编号",
          align: "center",
        },
      ],
      queryParams: {
        year: '',
        // num: '',
      }

    }
  },
  created() {
    if(!this.year){
      this.queryParams.year = new Date().getFullYear().toString();
    }else {
      this.queryParams.year = this.year;
    }
    this.getList();
  },
  methods:{
    getList() {
      this.$api.kjxm.acceptance.getIdeaNumByYear(this.queryParams.year).then(response => {
        this.data = response.data.map((val,index)=>({id:index,name:val}));
      }).catch((e) => {
        this.$message.error(e.toString());
      });
    },
    closeDialog() {
      this.$emit("update:visible", false);
    },
  }
}
</script>

<style scoped>

</style>
